package main

import (
	"bytes"
	"fmt"
	"os/exec"
)

func main() {
	cmd := exec.Command("ls", "-l", "/Users/iuqingzheng/*.log")
	var stdout, stderr bytes.Buffer
	cmd.Stdout = &stdout // 标准输出
	cmd.Stderr = &stderr // 标准错误
	err := cmd.Run()
	outStr, errStr := string(stdout.Bytes()), string(stderr.Bytes())
	fmt.Printf("标准输出:\n%s\n标准错误:\n%s\n", outStr, errStr)
	if err != nil {
		fmt.Println("执行出错：", err)
	}
}
